alert("init.js loaded");

var ServerJsLoaded = false;

function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}


function Start()
{
    alert('Starting APP !!!!!!!!!!!!!!!!!!!!!!!!!!');
    for (var w in CodeRepo.files)
    {
        alert(w);
        if (!CodeRepo.files[w])
        {
            alert('Failed to load '+w+'.js. Make sure You have added CodeRepo.SetReady line at the end of file!');
            //return;
        }
    }
    $.sfScene.show('Scene1');
	$.sfScene.focus('Scene1');
}

function CodeLoader() 
{
    this.files = new Array();
}
CodeLoader.prototype.Load = function(fileName)
{
    $.sf.loadJS('JavaScript/'+fileName+'.js');
    this.files[fileName] = false;
}
CodeLoader.prototype.SetReady = function(fileName)
{
    this.files[fileName] = true;
}

var CodeRepo = new CodeLoader();



function onStart () {
    CodeRepo.Load('Common');
    CodeRepo.Load('Profile');
    CodeRepo.Load('Logging');
    CodeRepo.Load('SceneManager');
    
    CodeRepo.Load('GData');
	CodeRepo.Load('Server');
    CodeRepo.Load('UserControl');
    CodeRepo.Load('UserControlGroup');
    CodeRepo.Load('Callback');
    CodeRepo.Load('ButtonCallback');
    
    
    
    setTimeout('Start()',1000);
}
function onDestroy () {
	//stop your XHR or Ajax operation and put codes to distroy your application here
	
}
